/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.seari.utils;

import com.seari.utils.common.AnimatedGifEncoder;
import java.awt.image.BufferedImage;
import java.io.FileOutputStream;
import java.io.OutputStream;

/**
 *
 * @author Rainbow
 */
public class ImageUtils
{
    private ImageUtils()
    {
        
    }
    
    public static void saveAnimatedImage(String fileName,BufferedImage[] imgs) throws Exception
    {
        FileOutputStream fos = new FileOutputStream(fileName);
        saveAnimatedImage(fos,imgs);
        fos.close();
    }
    
    public static void saveAnimatedImage(OutputStream out,BufferedImage[] imgs) throws Exception
    {
        AnimatedGifEncoder e = new AnimatedGifEncoder();
        e.start(out);
        e.setDelay(300);
        e.setRepeat(0);
        for(BufferedImage bi:imgs)
            e.addFrame(bi);
        e.finish();
        out.flush();
    }
}
